package com.mushuilingfeng.ddd.user.domain.org.vo;

import cn.hutool.core.util.StrUtil;
import com.mushuilingfeng.ddd.user.domain.base.DomainArgumentException;
import com.mushuilingfeng.ddd.user.domain.org.entity.Org;
import com.mushuilingfeng.ddd.framework.vo.IDomainValueObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author
 * @date 2024/9/18
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Getter
public class OrgApplyRequest implements IDomainValueObject {
    private Date applyTime;
    private String applyReason;
    private String applyUserName;
    private String applyUserTel;
    private String applyUserEmail;
    private String applyUserAddress;
    private Org applyOrg;

    @Override
    public void simpleCheckParams() {
        if (StrUtil.isBlankIfStr(applyReason)) {
            throw new DomainArgumentException("申请原因不能为空！");
        }
        if (StrUtil.isBlankIfStr(applyUserName)) {
            throw new DomainArgumentException("申请人姓名不能为空！");
        }
        if (StrUtil.isBlankIfStr(applyUserTel)) {
            throw new DomainArgumentException("申请人电话不能为空！");
        }
        if (StrUtil.isBlankIfStr(applyUserEmail)) {
            throw new DomainArgumentException("申请人邮箱不能为空！");
        }
        if (StrUtil.isBlankIfStr(applyUserAddress)) {
            throw new DomainArgumentException("申请人地址不能为空！");
        }
        if (null == applyOrg) {
            throw new DomainArgumentException("申请组织不能为空！");
        }
        applyOrg.simpleCheckParams();
    }
}
